package edu.mcw.rgd.clinminer.umls.type;

import edu.mcw.rgd.clinminer.data.ClinminerException;

public class AUI {

	private String aui;

	public AUI(String aui) throws ClinminerException {
		if (aui != null && aui.matches("A\\d+")) {
			this.aui = aui;
		} else {
			throw new ClinminerException("Invalid UMLS aui " + aui);
		}

	}

	@Override
	public String toString() {
		return aui;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((aui == null) ? 0 : aui.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj) {
			return true;
		}
		if (obj == null) {
			return false;
		}
		if (getClass() != obj.getClass()) {
			return false;
		}
		AUI other = (AUI) obj;
		if (aui == null) {
			if (other.aui != null) {
				return false;
			}
		} else if (!aui.equals(other.aui)) {
			return false;
		}
		return true;
	}

}
